package com.rockcypress.common.agent.dto;

import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author bolin
 * @create 2020-05-14 3:06 下午
 * @desc
 */
@Data
public class PortForwardDTO implements Serializable {

    private static final long serialVersionUID = 6202314348595169593L;

    private String host;

    private Integer localPort;

    private String remoteHost;

    private Integer remotePort;

    public PortForwardDTO(String host, Integer localPort, String remoteHost, Integer remotePort) {
        this.host = host;
        this.localPort = localPort;
        this.remoteHost = remoteHost;
        this.remotePort = remotePort;
    }

    @Override
    public String toString() {
        return "本地端口[" + localPort + "]通过[" + host + "]转发至[" + remoteHost + ":" + remotePort + "]";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PortForwardDTO that = (PortForwardDTO) o;
        return Objects.equals(host, that.host) &&
                Objects.equals(localPort, that.localPort) &&
                Objects.equals(remoteHost, that.remoteHost) &&
                Objects.equals(remotePort, that.remotePort);
    }

    @Override
    public int hashCode() {
        return Objects.hash(host, localPort, remoteHost, remotePort);
    }
}
